<?php
namespace wlcat\http\model;
use wlcat\src\Sql;

class Model extends Sql
{
    protected $_model;
    protected $_table;
    function __construct()
    {
        // 连接数据库
        $this->connect(C('db.host'), C('db.user'), C('db.password'), C('db.name'));
        // 获取模型名称
        $this->_model = get_class($this);
        $this->_model = rtrim($this->_model, 'Model');
        $this->_model = explode('\\',$this->_model);
        if (empty($this->_table))
        {
            // 数据库表名与类名一致
            $this->_table = strtolower($this->_model[count($this->_model)-1]);
        }
    }
    public function getTable()
    {
        return $this->_table;
    }
    function __destruct()
    {
    }
}